<!-- Контейнер виджета На любую соцсеть -->
<div class="max-widget-container">
  
  <!-- Всплывающее инфо-окно терминала -->
  <div class="max-pda-popup" id="maxPdaPopup">
    <div class="max-popup-header">
      <span class="max-led"></span>
      <div class="max-popup-title">На любую соцсеть</div>
      <button class="max-close-btn" id="maxCloseBtn">&times;</button>
    </div>
    <div class="max-popup-body">
      <p class="max-popup-text">Пишите любой текст</p>
      
      <!-- Ссылка на ваш реальный канал или сайт. Замените URL на свой -->
      <a href="https://example.com" target="_blank" class="max-connect-btn">Кнопка</a>
    </div>
    <div class="max-popup-footer">КОД ДОСТУПА: SECURE_LINE_OK</div>
  </div>

  <!-- Круглая плавающая кнопка вызова -->
  <button class="max-floating-button" id="maxWidgetBtn" title="Сайт или мессенджер">
    <span class="max-icon">M</span>
    <span class="max-pulse"></span>
  </button>
</div>

<style>
/* Базовое позиционирование виджета */
.max-widget-container {
  position: fixed;
  bottom: 25px;
  right: 25px;
  z-index: 99999;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Стили плавающей кнопки */
.max-floating-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #0c0c0e;
  border: 2px solid #dc2626; /* Красный неоновый акцент в стиле Hellgate */
  box-shadow: 0 0 15px rgba(220, 38, 38, 0.4);
  color: #dc2626;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  outline: none;
  transition: all 0.3s ease;
}
.max-floating-button:hover {
  transform: scale(1.05);
  background: #141417;
  box-shadow: 0 0 25px rgba(220, 38, 38, 0.7);
}

/* Эффект пульсации кнопки, чтобы привлекать внимание */
.max-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid #dc2626;
  animation: max-pulse-anim 2s infinite;
  pointer-events: none;
}

/* Окно терминала (Попап) */
.max-pda-popup {
  position: absolute;
  bottom: 75px;
  right: 0;
  width: 300px;
  background: #0c0c0e;
  border: 2px solid #3f3f46;
  border-top: 4px solid #dc2626;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7), 0 0 15px rgba(220, 38, 38, 0.15);
  display: none; /* Изначально скрыто */
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(15px);
  transition: all 0.3s ease;
}
.max-pda-popup.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* Шапка окна */
.max-popup-header {
  background: #141417;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #27272a;
}
.max-led {
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 6px #22c55e;
}
.max-popup-title {
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
  flex: 1;
}
.max-close-btn {
  background: none;
  border: none;
  color: #71717a;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.max-close-btn:hover { color: #ef4444; }

/* Тело окна */
.max-popup-body {
  padding: 15px;
  background: #09090b;
}
.max-popup-text {
  font-size: 12.5px;
  color: #a1a1aa;
  line-height: 1.5;
  margin: 0 0 15px 0;
}
.max-connect-btn {
  display: block;
  text-align: center;
  background: #18181b;
  border: 1px solid #dc2626;
  color: #ffffff;
  padding: 10px;
  font-size: 12px;
  font-weight: bold;
  text-decoration: none;
  letter-spacing: 0.5px;
  border-radius: 4px;
  transition: all 0.2s ease;
  box-shadow: 0 0 10px rgba(220, 38, 38, 0.1);
}
.max-connect-btn:hover {
  background: #dc2626;
  color: #ffffff;
  box-shadow: 0 0 15px rgba(220, 38, 38, 0.4);
}

/* Подвал окна */
.max-popup-footer {
  background: #141417;
  padding: 6px 15px;
  font-size: 9px;
  color: #52525b;
  border-top: 1px solid #27272a;
  text-align: right;
}

/* Анимация пульсации */
@keyframes max-pulse-anim {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}
</style>

<script>
document.addEventListener("DOMContentLoaded", function() {
  const widgetBtn = document.getElementById('maxWidgetBtn');
  const closeBtn = document.getElementById('maxCloseBtn');
  const popup = document.getElementById('maxPdaPopup');

  // Открытие / Закрытие по клику на круглую кнопку
  widgetBtn.addEventListener('click', function(e) {
    e.stopPropagation();
    if(popup.classList.contains('active')) {
      closePopup();
    } else {
      popup.style.display = 'flex';
      // Небольшой хак для плавного появления свойства display:flex
      setTimeout(() => popup.classList.add('active'), 10); 
    }
  });

  // Закрытие по крестику
  closeBtn.addEventListener('click', function(e) {
    e.stopPropagation();
    closePopup();
  });

  // Закрытие при клике в любое другое место экрана
  document.addEventListener('click', function(e) {
    if (!popup.contains(e.target) && e.target !== widgetBtn) {
      closePopup();
    }
  });

  function closePopup() {
    popup.classList.remove('active');
    setTimeout(() => {
      if(!popup.classList.contains('active')) popup.style.display = 'none';
    }, 300); // Соответствует длительности transition (0.3s)
  }
});
</script>
